using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SoundEffect : MonoBehaviour
{
    private AudioSource audioSource;

    [SerializeField]
    private AudioClip addScore;

    [SerializeField]
    private AudioClip failed;

    [SerializeField]
    private AudioClip tap;

    // Start is called before the first frame update
    void Start()
    {
        audioSource = gameObject.GetComponent<AudioSource>();

        GlobalEventManager.OnScoreChange += playScoreSound;
        GlobalEventManager.OnGameOver += playFailSound;
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    void playScoreSound(int score)
    {
        audioSource.clip = addScore;
        audioSource.Play();
    }

    void playFailSound()
    {
        audioSource.clip = failed;
        audioSource.Play();
    }
}
